package com.example.demo.Controller;

import com.example.demo.Entity.Operation;
import com.example.demo.Entity.selectionValue;
import com.example.demo.Server.selectionValueServer;
import com.google.gson.Gson;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
public class selectionValueController {

    @Autowired
    selectionValueServer server;

    @Autowired
    Gson gson;

    /************ 1查询所有操作记录 ***************/

    @ResponseBody
    @CrossOrigin
    @RequestMapping(value = "/findDepartmentList")
    public List<selectionValue> findDepartmentList(){
        //查询所以记录
        System.out.println("10查询选择框成功");
        return server.findDepartmentList();
    }


    /************ 2查询所有操作记录 ***************/

    @ResponseBody
    @CrossOrigin
    @RequestMapping(value = "/findAreaList")
    public List<selectionValue> findAreaList(){
        //查询所以记录
        System.out.println("9查询选择框成功");
        return server.findAreaList();
    }

    /************ 3查询所有操作记录 ***************/

    @ResponseBody
    @CrossOrigin
    @RequestMapping(value = "/findTypeOneList")
    public List<selectionValue> findTypeOneList(){
        //查询所以记录
        System.out.println("8查询选择框成功");
        return server.findTypeOneList();
    }

    /************ 4查询所有操作记录 ***************/

    @ResponseBody
    @CrossOrigin
    @RequestMapping(value = "/findTypeTwoList")
    public List<selectionValue> findTypeTwoList(){
        //查询所以记录
        System.out.println("7查询选择框成功");
        return server.findTypeTwoList();
    }

    /************ 5查询所有操作记录 ***************/

    @ResponseBody
    @CrossOrigin
    @RequestMapping(value = "/findFinancialFocusList")
    public List<selectionValue> findFinancialFocusList(){
        //查询所以记录
        System.out.println("6查询选择框成功");
        return server.findFinancialFocusList();
    }


    /************ 6查询所有操作记录 ***************/

    @ResponseBody
    @CrossOrigin
    @RequestMapping(value = "/findTypeFourList")
    public List<selectionValue> findTypeFourList(){
        //查询所以记录
        System.out.println("5查询选择框成功");
        return server.findTypeFourList();
    }


    /************ 7查询所有操作记录 ***************/

    @ResponseBody
    @CrossOrigin
    @RequestMapping(value = "/findTypeFiveList")
    public List<selectionValue> findTypeFiveList(){
        //查询所以记录
        System.out.println("4查询选择框成功");
        return server.findTypeFiveList();
    }

    /************ 8查询所有操作记录 ***************/

    @ResponseBody
    @CrossOrigin
    @RequestMapping(value = "/findTypeSixList")
    public List<selectionValue> findTypeSixList(){
        //查询所以记录
        System.out.println("3查询选择框成功");
        return server.findTypeSixList();
    }

    /************ 9查询所有操作记录 ***************/

    @ResponseBody
    @CrossOrigin
    @RequestMapping(value = "/findSpecsList")
    public List<selectionValue> findSpecsList(){
        //查询所以记录
        System.out.println("2查询选择框成功");
        return server.findSpecsList();
    }

    /************ 10查询所有操作记录 ***************/

    @ResponseBody
    @CrossOrigin
    @RequestMapping(value = "/findCompanyList")
    public List<selectionValue> findCompanyList(){
        //查询所以记录
        System.out.println("1查询选择框成功");
        return server.findAllSelect();
    }

    /************ 添加 ***************/


    @ResponseBody
    @CrossOrigin
    @RequestMapping(value = "/addCompanyList",method = RequestMethod.POST,produces = "application/json;charset=UTF-8")
    public String addCompanyList(@RequestBody String data){

       selectionValue s = gson.fromJson(data,selectionValue.class);
       server.addCompanyList(s);
       return "success";
    }

    @ResponseBody
    @CrossOrigin
    @RequestMapping(value = "/addDepartmentList")
    public String addDepartmentList(@RequestBody String data){
        selectionValue s = gson.fromJson(data,selectionValue.class);
        server.addDepartmentList(s);
        return "success";
    }

    @ResponseBody
    @CrossOrigin
    @RequestMapping(value = "/addAreaList")
    public String addAreaList(@RequestBody String data){
        selectionValue s = gson.fromJson(data,selectionValue.class);
        server.addAreaList(s);
        return "success";
    }

    @ResponseBody
    @CrossOrigin
    @RequestMapping(value = "/addTypeOneList")
    public String addTypeOneList(@RequestBody String data){
        selectionValue s = gson.fromJson(data,selectionValue.class);
        server.addTypeOneList(s);
        return "success";
    }

    @ResponseBody
    @CrossOrigin
    @RequestMapping(value = "/addTypeTwoList")
    public String addTypeTwoList(@RequestBody String data){
        selectionValue s = gson.fromJson(data,selectionValue.class);
        server.addTypeTwoList(s);
        return "success";
    }


    @ResponseBody
    @CrossOrigin
    @RequestMapping(value = "/addFinancialFocusList")
    public String addFinancialFocusList(@RequestBody String data){
        selectionValue s = gson.fromJson(data,selectionValue.class);
        server.addFinancialFocusList(s);
        return "success";
    }

    @ResponseBody
    @CrossOrigin
    @RequestMapping(value = "/addTypeFourList")
    public String addTypeFourList(@RequestBody String data){
        selectionValue s = gson.fromJson(data,selectionValue.class);
        server.addTypeFourList(s);
        return "success";
    }

    @ResponseBody
    @CrossOrigin
    @RequestMapping(value = "/addTypeFiveList")
    public String addTypeFiveList(@RequestBody String data){
        selectionValue s = gson.fromJson(data,selectionValue.class);
        server.addTypeFiveList(s);
        return "success";
    }

    @ResponseBody
    @CrossOrigin
    @RequestMapping(value = "/addTypeSixList")
    public String addTypeSixList(@RequestBody String data){
        selectionValue s = gson.fromJson(data,selectionValue.class);
        server.addTypeSixList(s);
        return "success";
    }

    @ResponseBody
    @CrossOrigin
    @RequestMapping(value = "/addSpecsList")
    public String addSpecsList(@RequestBody String data){
        selectionValue s = gson.fromJson(data,selectionValue.class);
        server.addSpecsList(s);
        return "success";
    }

    /******************** 删除 **********************/
    @ResponseBody
    @RequestMapping(value = "/deleteDepartmentList",method = RequestMethod.POST,produces = "application/json;charset=UTF-8")
    @CrossOrigin
    public String deleteDepartmentList(@RequestBody String data) {
        selectionValue s = gson.fromJson(data,selectionValue.class);
        //如果删除成功返回success,失败返回lose
        return server.deleteDepartmentList(s) == 1?"success":"lose";
    }
    @ResponseBody
    @RequestMapping(value = "/deleteAreaList",method = RequestMethod.POST,produces = "application/json;charset=UTF-8")
    @CrossOrigin
    public String deleteAreaList(@RequestBody String data) {
        selectionValue s = gson.fromJson(data,selectionValue.class);
        //如果删除成功返回success,失败返回lose
        return server.deleteAreaList(s) == 1?"success":"lose";
    }

    @ResponseBody
    @RequestMapping(value = "/deleteTypeOneList",method = RequestMethod.POST,produces = "application/json;charset=UTF-8")
    @CrossOrigin
    public String deleteTypeOneList(@RequestBody String data) {
        selectionValue s = gson.fromJson(data,selectionValue.class);
        //如果删除成功返回success,失败返回lose
        return server.deleteTypeOneList(s) == 1?"success":"lose";
    }

    @ResponseBody
    @RequestMapping(value = "/deleteTypeTwoList",method = RequestMethod.POST,produces = "application/json;charset=UTF-8")
    @CrossOrigin
    public String deleteTypeTwoList(@RequestBody String data) {
        selectionValue s = gson.fromJson(data,selectionValue.class);
        //如果删除成功返回success,失败返回lose
        return server.deleteTypeTwoList(s) == 1?"success":"lose";
    }

    @ResponseBody
    @RequestMapping(value = "/deleteFinancialFocusList",method = RequestMethod.POST,produces = "application/json;charset=UTF-8")
    @CrossOrigin
    public String deleteFinancialFocusList(@RequestBody String data) {
        selectionValue s = gson.fromJson(data,selectionValue.class);
        //如果删除成功返回success,失败返回lose
        return server.deleteFinancialFocusList(s) == 1?"success":"lose";
    }

    @ResponseBody
    @RequestMapping(value = "/deleteTypeFourList",method = RequestMethod.POST,produces = "application/json;charset=UTF-8")
    @CrossOrigin
    public String deleteTypeFourList(@RequestBody String data) {
        selectionValue s = gson.fromJson(data,selectionValue.class);
        //如果删除成功返回success,失败返回lose
        return server.deleteTypeFourList(s) == 1?"success":"lose";
    }

    @ResponseBody
    @RequestMapping(value = "/deleteTypeFiveList",method = RequestMethod.POST,produces = "application/json;charset=UTF-8")
    @CrossOrigin
    public String deleteTypeFiveList(@RequestBody String data) {
        selectionValue s = gson.fromJson(data,selectionValue.class);
        //如果删除成功返回success,失败返回lose
        return server.deleteTypeFiveList(s) == 1?"success":"lose";
    }

    @ResponseBody
    @RequestMapping(value = "/deleteTypeSixList",method = RequestMethod.POST,produces = "application/json;charset=UTF-8")
    @CrossOrigin
    public String deleteTypeSixList(@RequestBody String data) {
        selectionValue s = gson.fromJson(data,selectionValue.class);
        //如果删除成功返回success,失败返回lose
        return server.deleteTypeSixList(s) == 1?"success":"lose";
    }

    @ResponseBody
    @RequestMapping(value = "/deleteCompanyList",method = RequestMethod.POST,produces = "application/json;charset=UTF-8")
    @CrossOrigin
    public String deleteCompanyList(@RequestBody String data) {
        selectionValue s = gson.fromJson(data,selectionValue.class);
        //如果删除成功返回success,失败返回lose
        return server.deleteCompanyList(s) == 1?"success":"lose";
    }

    @ResponseBody
    @RequestMapping(value = "/deleteSpecsList",method = RequestMethod.POST,produces = "application/json;charset=UTF-8")
    @CrossOrigin
    public String deleteSpecsList(@RequestBody String data) {
        selectionValue s = gson.fromJson(data,selectionValue.class);
        //如果删除成功返回success,失败返回lose
        return server.deleteSpecsList(s) == 1?"success":"lose";
    }
}
